#ifndef __SMEG_PLACEABLE_HPP__
#define __SMEG_PLACEABLE_HPP__

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <SFML/Graphics/Transformable.hpp>
#include <SFML/Graphics/Drawable.hpp>

// Translation
#define COORDINATE_HALF_WIDTH   2.5f
#define COORDINATE_SIZE         100
#define SQUARE_COORDINATE_SIZE  50

// Rotation
#define MIN_ROTATION_SIZE       40
#define MAX_ROTATION_SIZE       60
#define SQR_MIN_ROTATION_SIZE   MIN_ROTATION_SIZE * MIN_ROTATION_SIZE
#define SQR_MAX_ROTATION_SIZE   MAX_ROTATION_SIZE * MAX_ROTATION_SIZE

#define OPACITY_SELECTED        255
#define OPACITY_NOT_SELECTED    120

class SmegPlaceable : public sf::Drawable, public sf::Transformable
{
public:
    enum eDragEnum {
        eDrag_Translation_X,
        eDrag_Translation_Y,
        eDrag_Translation_ALL,
        eDrag_Rotation,
        eDrag_None,
    };

    enum eModeEnum {
        eMode_Translation,
        eMode_Rotation,
        eMode_None,
    };

                    SmegPlaceable();
                    
    eDragEnum       BeginDragSelection( const sf::Vector2f& _MouseBeginDrag );
    void            DragSelection( const sf::Vector2f& _MouseDrag );
    void            StopDragSelection();

    eDragEnum       SetSelection( const sf::Vector2f& _MousePos );
    void            ResetSelection();

    void            SetMode( eModeEnum _eNewMode );
    eModeEnum       GetMode() const;

private:
    virtual void    draw(sf::RenderTarget& target, sf::RenderStates states) const;
    
    sf::Uint8       m_XCoordinateSelected;
    sf::Uint8       m_YCoordinateSelected;
    sf::Uint8       m_XYCoordinateSelected;
    sf::Uint8       m_RotationCoordinateSelected;

    eModeEnum       m_eMode;
    eDragEnum       m_eDraggingType;
    sf::Vector2f    m_LastDragPos;          // For translation
    float           m_fCurrentAngle;        // For rotation
};

inline void SmegPlaceable::SetMode( eModeEnum _eNewMode ) {
    m_eMode = _eNewMode;
}

inline SmegPlaceable::eModeEnum SmegPlaceable::GetMode() const {
    return m_eMode;
}

#endif // __SMEG_PLACEABLE_HPP__